<template>
  <div class="tenant-detail-container">
    <ContentWrap class="detail-wrapper">
      <!-- 页面头部 -->
      <div class="detail-header">
        <div class="header-icon">
          <Icon icon="ep:setting" />
        </div>
        <div class="header-content">
          <h3 class="detail-title">租户配置</h3>
          <p class="detail-subtitle">管理租户的详细配置信息</p>
        </div>
      </div>

      <!-- 标签页容器 -->
      <div class="tabs-container">
        <el-tabs v-model="activeName" tab-position="top" class="enhanced-tabs">
          <el-tab-pane label="基本配置" name="1" class="tab-pane">
            <div class="tab-label">
              <Icon icon="ep:info-filled" class="tab-icon" />
              <span>基本配置</span>
            </div>
          </el-tab-pane>

          <el-tab-pane label="角色配置" name="2" class="tab-pane">
            <div class="tab-label">
              <Icon icon="ep:user" class="tab-icon" />
              <span>角色配置</span>
            </div>
          </el-tab-pane>

          <el-tab-pane label="部门配置" name="3" class="tab-pane">
            <div class="tab-label">
              <Icon icon="ep:office-building" class="tab-icon" />
              <span>部门配置</span>
            </div>
          </el-tab-pane>

          <el-tab-pane label="用户配置" name="4" class="tab-pane">
            <div class="tab-label">
              <Icon icon="ep:avatar" class="tab-icon" />
              <span>用户配置</span>
            </div>
          </el-tab-pane>

          <el-tab-pane label="坐席配置" name="5" class="tab-pane">
            <div class="tab-label">
              <Icon icon="ep:headset" class="tab-icon" />
              <span>坐席配置</span>
            </div>
          </el-tab-pane>

          <el-tab-pane label="充值记录" name="6" class="tab-pane">
            <div class="tab-label">
              <Icon icon="ep:wallet" class="tab-icon" />
              <span>充值记录</span>
            </div>
          </el-tab-pane>

          <el-tab-pane label="租户附件" name="7" class="tab-pane">
            <div class="tab-label">
              <Icon icon="ep:folder" class="tab-icon" />
              <span>租户附件</span>
            </div>
          </el-tab-pane>

          <!-- 标签页内容 -->
          <div class="tab-content">
            <!-- 基本配置 -->
            <BasicConfiguration v-if="activeName == '1'" :configureId="configureId" />
            <!-- 角色配置 -->
            <RoleConfiguration v-if="activeName == '2'" :configureId="configureId" />
            <!-- 部门配置 -->
            <DepartmentConfiguration v-if="activeName == '3'" :configureId="configureId" />
            <!-- 用户配置 -->
            <AccountConfiguration v-if="activeName == '4'" :configureId="configureId" />
            <!-- 坐席分配 -->
            <SeatAllocation v-if="activeName == '5'" :configureId="configureId" />
            <!-- 充值记录 -->
            <RechargeLogTable v-if="activeName == '6'" :configureId="configureId" />
            <!-- 附件 -->
            <FileTable v-if="activeName == '7'" :configureId="configureId" />
          </div>
        </el-tabs>
      </div>
    </ContentWrap>
  </div>
</template>

<script setup>
import log from '@/utils/log'
import { Tickets } from '@element-plus/icons-vue'
import BasicConfiguration from './components/BasicConfiguration.vue'
import RoleConfiguration from './components/roleConfiguration.vue'
import DepartmentConfiguration from './components/departmentConfiguration.vue'
import AccountConfiguration from './components/AccountConfiguration.vue'
import SeatAllocation from './components/SeatAllocation.vue'
import RobotCallConfiguration from './components/RobotCallConfiguration.vue'
import RechargeLogTable from './components/RechargeLogTable.vue'
import FileTable from './components/FileTable.vue'

const { query } = useRoute()
const configureId = ref('')
const activeName = ref('1')

onMounted(() => {
  log.success('id', query?.id)
  configureId.value = query?.id
})
</script>

<style lang="scss" scoped>
// 主题色变量
$primary-color: #0052cc;
$primary-light: rgba(0, 82, 204, 0.1);
$primary-border: rgba(0, 82, 204, 0.3);
$success-color: #67c23a;
$warning-color: #e6a23c;
$danger-color: #f56c6c;
$info-color: #909399;
$text-primary: #303133;
$text-regular: #606266;
$text-secondary: #909399;
$text-placeholder: #c0c4cc;
$border-color: #dcdfe6;
$border-light: #e4e7ed;
$bg-color: #f5f7fa;
$shadow-light: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
$shadow-base:
  0 2px 4px rgba(0, 0, 0, 0.12),
  0 0 6px rgba(0, 0, 0, 0.04);
$border-radius: 12px;
$border-radius-small: 8px;

.tenant-detail-container {
  padding: 16px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: 100vh;

  @media (max-width: 768px) {
    padding: 8px;
  }
}

.detail-wrapper {
  border-radius: $border-radius;
  overflow: hidden;
  box-shadow: $shadow-light;
  border: 1px solid $border-light;

  :deep(.el-card__body) {
    padding: 0;
  }
}

/* 页面头部 */
.detail-header {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  background: linear-gradient(135deg, $primary-color 0%, #1d4ed8 100%);
  color: white;
  border-bottom: 1px solid $border-light;

  @media (max-width: 768px) {
    padding: 16px;
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}

.header-icon {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: $border-radius-small;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;

  @media (max-width: 768px) {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}

.header-content {
  flex: 1;
  margin-left: 16px;

  @media (max-width: 768px) {
    margin-left: 0;
  }
}

.detail-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px 0;

  @media (max-width: 768px) {
    font-size: 18px;
  }
}

.detail-subtitle {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;

  @media (max-width: 768px) {
    font-size: 12px;
  }
}

/* 标签页容器 */
.tabs-container {
  background: white;
  padding: 0;
}

.enhanced-tabs {
  :deep(.el-tabs__header) {
    margin: 0;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f2ff 100%);
    padding: 0 24px;
    border-bottom: 2px solid $border-light;

    @media (max-width: 768px) {
      padding: 0 16px;
    }
  }

  :deep(.el-tabs__nav-wrap) {
    &::after {
      display: none;
    }

    @media (max-width: 768px) {
      overflow-x: auto;
      overflow-y: hidden;

      &::-webkit-scrollbar {
        height: 3px;
      }

      &::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
      }

      &::-webkit-scrollbar-thumb {
        background: rgba(0, 82, 204, 0.3);
        border-radius: 2px;
      }
    }
  }

  :deep(.el-tabs__nav) {
    @media (max-width: 768px) {
      white-space: nowrap;
      min-width: max-content;
    }
  }

  :deep(.el-tabs__item) {
    font-weight: 500;
    color: $text-regular;
    padding: 16px 20px;
    transition: all 0.3s ease;
    border-radius: $border-radius-small $border-radius-small 0 0;
    margin-right: 4px;
    position: relative;
    overflow: hidden;

    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: transparent;
      transition: all 0.3s ease;
      z-index: 0;
    }

    &:hover {
      color: $primary-color;
      background: rgba(0, 82, 204, 0.05);

      &::before {
        background: linear-gradient(135deg, rgba(0, 82, 204, 0.1) 0%, rgba(29, 78, 216, 0.1) 100%);
      }
    }

    &.is-active {
      color: $primary-color;
      font-weight: 600;
      background: white;
      box-shadow: 0 -2px 8px rgba(0, 82, 204, 0.1);

      &::before {
        background: linear-gradient(
          135deg,
          rgba(0, 82, 204, 0.05) 0%,
          rgba(29, 78, 216, 0.05) 100%
        );
      }
    }

    @media (max-width: 768px) {
      padding: 12px 16px;
      font-size: 14px;
      margin-right: 2px;
      flex-shrink: 0;
    }
  }

  :deep(.el-tabs__active-bar) {
    background: linear-gradient(135deg, $primary-color 0%, #1d4ed8 100%);
    height: 3px;
    border-radius: 2px;
    transition: all 0.3s ease;
  }

  :deep(.el-tabs__content) {
    padding: 0;
  }

  :deep(.el-tab-pane) {
    padding: 0;
  }
}

.tab-label {
  display: none;

  @media (max-width: 768px) {
    display: flex;
    align-items: center;
    gap: 6px;
  }
}

.tab-icon {
  font-size: 14px;
  flex-shrink: 0;
}

/* 标签页内容 */
.tab-content {
  padding: 24px;
  background: white;
  min-height: 500px;

  @media (max-width: 768px) {
    padding: 16px;
    min-height: 400px;
  }
}

/* 响应式优化 */
@media (max-width: 480px) {
  .tenant-detail-container {
    padding: 4px;
  }

  .detail-header {
    padding: 12px 16px;
  }

  .enhanced-tabs {
    :deep(.el-tabs__header) {
      padding: 0 12px;
    }

    :deep(.el-tabs__item) {
      padding: 10px 12px;
      font-size: 13px;
    }
  }

  .tab-content {
    padding: 12px;
  }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .tenant-detail-container {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  }

  .detail-wrapper {
    background: #374151;
    border-color: #4b5563;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  .tabs-container,
  .tab-content {
    background: #374151;
  }

  .detail-title {
    color: #f9fafb;
  }

  .enhanced-tabs {
    :deep(.el-tabs__header) {
      background: #4b5563;
      border-color: #6b7280;
    }

    :deep(.el-tabs__item) {
      color: #d1d5db;

      &:hover {
        color: #60a5fa;
        background: rgba(96, 165, 250, 0.1);
      }

      &.is-active {
        color: #60a5fa;
        background: #374151;
        box-shadow: 0 -2px 8px rgba(96, 165, 250, 0.1);
      }
    }

    :deep(.el-tabs__active-bar) {
      background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    }
  }
}

/* 加载状态优化 */
:deep(.el-loading-mask) {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(2px);

  .el-loading-spinner {
    .path {
      stroke: $primary-color;
    }
  }
}

/* 标签页切换动画 */
.tab-content {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 标签页悬浮效果 */
.enhanced-tabs {
  :deep(.el-tabs__item) {
    &:hover {
      transform: translateY(-1px);
      box-shadow: 0 2px 8px rgba(0, 82, 204, 0.15);
    }

    &.is-active {
      transform: translateY(-2px);
    }
  }
}
</style>
